-- cmd_dungeon_action
-- Create by panyl
-- 地牢行为

function Operation.cmd_dungeon_action(identify, actions)
    -- 当前层
    local layer = DungeonM.currentLayer();

    -- 最后的属性
    DungeonLogM.collectFinalData(layer);

    -- 行为队列是空的
    if #actions <= 0 then
        return;
    end

    -- 把所有操作都连接成一个buffer
    local buf = Buffer.create(0);
    for _, action in pairs(actions) do
        buf = Buffer.append(buf, action);
    end

    -- 获取随机数游标
    local randomCursor = RandomFactoryM.packRandomCursor();

    -- 等待应答id（一个唯一的id）
    local authId = os.time();

    local v = {
        ["identify"]    = identify,
        ["auth_id"]     = authId,
        ["layer"]       = layer,
        ["cursor"]      = randomCursor.value,
        ["args"]        = buf.value,
        ["attrib"]      = SimpleEncryptM.collectAttribCoding(ME.user),
    };

    -- 等待队列
    DungeonServiceM.addWaitSync("CMD_DUNGEON_ACTION", v);
end
